﻿using Domain.Entities;
using Domain.IRepositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Application.RoleMenuApp
{
    public class RoleMenuAppService : IRoleMenuAppService
    {

        //用户管理仓储接口
        private readonly IRoleMenuRepository _repository;

        /// <summary>
        /// 构造函数 实现依赖注入
        /// </summary>
        /// <param name="RoleMenuRepository">仓储对象</param>
        public RoleMenuAppService(IRoleMenuRepository RoleMenuRepository)
        {
            _repository = RoleMenuRepository;
        }

        public RoleMenu GetById(Int32 id)
        {
            return _repository.GetById(id);
        }

        public List<RoleMenu> GetAll(string key)
        {
            return _repository.GetAll(key).ToList();
        }

        public List<RoleMenu> GetPageList(string SearchKeyWords, int PageSize, int PageCurrent, string OrderField, bool OrderDirection = true)
        {

            return _repository.GetPageList(SearchKeyWords, PageSize, PageCurrent, OrderField, OrderDirection).ToList();
        }
        public bool AddOrUpdate(RoleMenu model)
        {
            return _repository.AddOrUpdate(model);
        }

        public bool DeleteById(int id)
        {
            return _repository.DeleteById(id);
        }

        /// <summary>
        /// 根据roleID删除所有权限
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        public bool Delete(string roleid)
        {
            return _repository.Delete(roleid);
        }
    }
}
